﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>日记审核</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/js/plugin/bootstrap-table/bootstrap-table.min.css">
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
    <link rel="stylesheet" href="assets/css/ready.css">
    <link rel="stylesheet" href="assets/css/demo.css">
    <link rel="stylesheet" href="jQueryMsg/css/message.css">

    <style>
        .table td, .table th {
            padding: 0.25rem !important;
        }

        .fixed-table-container tbody td, .fixed-table-container thead th {
            padding: 0px;
        }

        #seeModal .modal-dialog {
            max-width: 1000px;
        }

        #seeModal .modal-body {
            min-height: 30rem;
        }
    </style>

</head>
<body style="min-width: 555px">
<div class="wrapper">
    <div class="main-header">

        <!--logo-->
        <div class="logo-header">
            <a href="index.html" class="logo">
                教学实训管理系统
            </a>
            <button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse"
                    data-target="collapse" aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
        </div>
        <nav class="navbar navbar-header navbar-expand-lg">
            <div class="container-fluid">


                <!--用户管理-->
                <ul class="navbar-nav topbar-nav ml-md-auto align-items-center">
                    <li class="nav-item dropdown hidden-caret">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <i class="la la-bell"></i>
                            <span id="messageLen" class="notification" style="display: none"></span>
                        </a>
                        <ul id="dialogueMessage" class="dropdown-menu notif-box" aria-labelledby="navbarDropdown">

                        </ul>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">
                            <img src="assets/img/profile.jpg" alt="user-img" width="36"
                                 class="img-circle"><span id="userName1"></span></span> </a>
                        <ul class="dropdown-menu dropdown-user">
                            <a id="resetPass" class="dropdown-item" href="#"><i class="fa fa-power-off"></i> 修改密码</a>
                            <a id="logout" class="dropdown-item" href="#"><i class="fa fa-power-off"></i> Logout</a>
                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="sidebar">
        <div class="sidebar-wrapper">

            <!--左侧导航-->
            <ul class="nav">
                <li class="nav-item">
                    <a href="index.html">
                        <i class="la la-dashboard"></i>
                        <p>home</p>
                        <!--<span class="badge badge-count">5</span>-->
                    </a>
                </li>
                <li id="1" style="display: none" class="nav-item">
                    <a href="user.html">
                        <i class="la la-table"></i>
                        <p>用户</p>
                        <!--<span class="badge badge-count">14</span>-->
                    </a>
                </li>
                <li id="2" style="display: none" class="nav-item">
                    <a href="role.html">
                        <i class="la la-keyboard-o"></i>
                        <p>角色</p>
                        <!--<span class="badge badge-count">50</span>-->
                    </a>
                </li>
                <li id="3" style="display: none" class="nav-item">
                    <a href="questions.html">
                        <i class="la la-th"></i>
                        <p>留言</p>
                        <!--<span class="badge badge-count">6</span>-->
                    </a>
                </li>
                <li id="4" style="display: none" class="nav-item">
                    <a href="submission.html">
                        <i class="la la-bell"></i>
                        <p>日记记录</p>
                        <!--<span class="badge badge-success">3</span>-->
                    </a>
                </li>
                <li id="5" style="display: none" class="nav-item active">
                    <a href="audit.html">
                        <i class="la la-font"></i>
                        <p>日记审核</p>
                        <span id="diaryLen" class="badge badge-danger"></span>
                    </a>
                </li>
            </ul>
        </div>
    </div>

    <!--main-->
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <h4 class="page-title">日记审核</h4>
                <!--表格-->
                <div class="row" style="margin-bottom: 2%">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header ">
                                <h4 class="card-title">日记审核 Table</h4>
                            </div>
                            <div class="card-body">
                                <table id="table" class="table table-hover">
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <footer class="footer">
            <div class="container-fluid">
                <nav class="pull-left">
                    <ul class="nav">
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                反馈
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                帮助
                            </a>
                        </li>
                    </ul>
                </nav>
                <div class="copyright ml-auto">
                    2020.07.22
                </div>
            </div>
        </footer>
    </div>
</div>
<!-- 查看模态框 -->
<div class="modal fade" id="seeModal">
    <div class="modal-dialog" style="margin-top: 5%">
        <div class="modal-content">
            <div class="modal-header">
                <h6 class="modal-title" id="seeModalLabel">日记</h6>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                <h6 id="diaryTitle" style="text-align: center"></h6>
                <hr/>
                <span id="diaryText"></span>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#fractionModal">打分
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<div class="modal fade" id="fractionModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog" style="    margin-top: 17%;border: 1px #dbdbdb solid;border-radius: 5px;">
        <div class="modal-content">
            <div class="modal-header">
                <h6 class="modal-title" id="deleteModalLabel">操作</h6>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group form-inline">
                        <label class="col-sm-3 control-label" for="fraction">选择分数</label>
                        <div class="col-sm-9">
                            <select id="fraction" class="form-control" style="width: 67%">
                                <option>优</option>
                                <option>良</option>
                                <option>差</option>
                                <option>不及格</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button id="fractionBtn" type="button" class="btn btn-primary">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<div class="modal fade" id="rejectModal">
    <div class="modal-dialog" style="margin-top: 10%;">
        <div class="modal-content">
            <div class="modal-header">
                <h6 class="modal-title" id="rejectModalLabel">操作</h6>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form">
                    <div class="form-group has-warning form-inline">
                        <label class="col-sm-3 control-label" for="remarks">建议</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="remarks" autocomplete="off">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button id="rejectBtn" type="button" class="btn btn-primary">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal">
    <div class="modal-dialog" style="margin-top: 10%;">
        <div class="modal-content">
            <div class="modal-header">
                <h6 class="modal-title" id="myModalLabel">操作</h6>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form">
                    <div class="form-group has-warning form-inline">
                        <label class="col-sm-3 control-label" for="oldPass">旧密码</label>
                        <div class="col-sm-9">
                            <input type="password" class="form-control" id="oldPass" placeholder="旧密码..." autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group has-warning form-inline">
                        <label class="col-sm-3 control-label" for="newPass">新密码</label>
                        <div class="col-sm-9">
                            <input type="password" class="form-control" id="newPass" placeholder="新密码..." autocomplete="off">
                        </div>
                    </div>
                    <div class="form-group has-warning form-inline">
                        <label class="col-sm-3 control-label" for="newPassTwo">确认密码</label>
                        <div class="col-sm-9">
                            <input type="password" class="form-control" id="newPassTwo" placeholder="确认密码..." autocomplete="off">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button id="setPass" type="button" class="btn btn-primary">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
<script src="assets/js/core/jquery.3.2.1.min.js"></script>
<!--<script src="assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>-->
<script src="assets/js/core/popper.min.js"></script>
<script src="assets/js/core/bootstrap.min.js"></script>
<script src="assets/js/plugin/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script src="assets/js/plugin/bootstrap-table/bootstrap-table.min.js"></script>
<!--<script src="assets/js/plugin/chartist/chartist.min.js"></script>-->
<!--<script src="assets/js/plugin/chartist/plugin/chartist-plugin-tooltip.min.js"></script>-->
<!--<script src="assets/js/plugin/bootstrap-notify/bootstrap-notify.min.js"></script>-->
<!--<script src="assets/js/plugin/bootstrap-toggle/bootstrap-toggle.min.js"></script>-->
<!--<script src="assets/js/plugin/jquery-mapael/jquery.mapael.min.js"></script>-->
<!--<script src="assets/js/plugin/jquery-mapael/maps/world_countries.min.js"></script>-->
<!--<script src="assets/js/plugin/chart-circle/circles.min.js"></script>-->
<script src="assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script src="jQueryMsg/js/message.js"></script>
<script src="assets/js/ready.min.js"></script>

<script>
    var token;
    $(function () {
        var oTable = new TableInit();
        oTable.Init();
        token = sessionStorage.getItem('token')
        getPower()
        dialogueMessage()
        audit();
    });
    var TableInit = function () {
        var oTableInit = new Object();
        oTableInit.Init = function () {
            $('#table').bootstrapTable({
                url: 'http://localhost:8080/oa/t-diary/listDiary1',
                type: 'GET',
                headers: {
                    token: "" + token
                },
                sidePagination: "client",
                pagination: true,
                pageNumber: 1,
                pageSize: 5,
                pageList: [5, 10, 25, 50, 100],
                height: 350,
                formatNoMatches: function(){
                    return "没有相关的匹配结果";
                },
                formatLoadingMessage: function(){
                    return "请稍等，正在加载中。。。";
                },
                columns: [{
                    checkbox: true,
                    visible: true
                }, {
                    field: 'diaryTitle',
                    title: '日记标题',
                    align: 'center'
                }, {
                    field: 'studentId',
                    title: '提交用户',
                    align: 'center'
                }, {
                    field: 'updateTime',
                    title: '更新时间',
                    align: 'center'
                }, {
                    field: 'operate',
                    title: '操作',
                    align: 'center',
                    events: operateEvents,
                    formatter: operateFormatter //自定义方法，添加操作按钮
                }]
            });
        }
        return oTableInit;
    }

    function operateFormatter(value, row, index) {//赋予的参数
        return [
            '<button class="seeModal btn btn-default btn-xs" style="margin: 0 5px 0 5px">查看</button>',
            '<button class="rejectModal btn btn-default btn-xs" style="margin: 0 5px 0 5px">驳回</button>',
        ].join('');
    }

    window.operateEvents = {
        //查看
        'click .seeModal': function (e, value, row, index) {
            $('#seeModal').modal('show');
            var param = {
                diaryId:row.diaryId
            }
            $.ajax({
                url: 'http://localhost:8080/oa/t-diary/listDiaryById',
                type: "GET",
                data: param,
                dataType: "json",
                headers: {
                    token: "" + token
                },
                success: function (data) {
                    if (data.code == 200){
                        $('#diaryTitle').html(data.data.diaryTitle)
                        $('#diaryText').html(decodeURIComponent(data.data.diaryText))
                    }else if (data.code == 401) {
                        window.location.href = 'login.html'
                    }else {
                        $.message({
                            message:data.msg,
                            type:'error'
                        });
                    }
                }
            })
            $('#fractionBtn').unbind('click').on('click',function () {
                var param = {
                    diaryId: row.diaryId,
                    fraction:$('#fraction').val(),
                    diaryState:3
                }
                $.ajax({
                    url: 'http://localhost:8080/oa/t-diary/updateDiaryState',
                    type: "POST",
                    data: JSON.stringify(param),
                    dataType: "json",
                    headers: {
                        token: "" + token
                    },
                    contentType: 'application/json; charset=UTF-8',
                    success: function (data) {
                        if (data.code == 200) {
                            $('#seeModal').modal('hide');
                            $('#fractionModal').modal('hide');
                            audit();
                            $('#table').bootstrapTable('refresh');
                        } else if (data.code == 401) {
                            window.location.href = 'login.html'
                        } else {
                            $.message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }
                })
            })
        },
        'click .rejectModal': function (e, value, row, index) {
            $('#rejectModal').modal('show');
            $('#rejectBtn').unbind('click').on('click',function () {
                var param = {
                    diaryId: row.diaryId,
                    remarks:$('#remarks').val(),
                    diaryState: 2
                }
                $.ajax({
                    url: 'http://localhost:8080/oa/t-diary/updateDiaryState',
                    type: "POST",
                    data: JSON.stringify(param),
                    dataType: "json",
                    headers: {
                        token: "" + token
                    },
                    contentType: 'application/json; charset=UTF-8',
                    success: function (data) {
                        if (data.code == 200) {
                            $('#rejectModal').modal('hide');
                            audit();
                            $('#table').bootstrapTable('refresh');
                        } else if (data.code == 401) {
                            window.location.href = 'login.html'
                        } else {
                            $.message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }
                })
            })

        }
    };
</script>
<script src="power.js"></script>

</html>